using System;
using System.Collections.Generic;
using System.Text;
using PlaceFinder.BO;
using PlaceFinder.DAL.Interfaces;
using System.Xml;
using PlaceFinder.DAL.Common;

namespace PlaceFinder.DAL
{
    public class PlaceDAO: DAOBase<Place>, IPlaceDAO
    {

        #region IPlaceDAO Members

        public List<Place> GetByCategory(int categoryId)
        {            
            return _xmlDB.Get(p=>p.CategoryId == categoryId);
        }

        #endregion

        #region IDAL<int,Place> Members

        public Place FindById(int id)
        {
            List<Place> list = _xmlDB.Get(p => p.Id == id);
            Place place = null;
            if (list.Count > 0)
                place = list[0];
            return place;
        }

        public List<Place> Find(string matchWord)
        {
            return _xmlDB.Get(p => p.Description.Contains(matchWord));
        }

        #endregion

        public List<Place> GetByFloor(int floorNumber)
        {
            return _xmlDB.Get(p => p.Floor == floorNumber);
        }
    }
}
